package com.example.Task;

import com.example.mapper.ApartmentMapper;
import com.example.mapper.IndentMapper;
import com.example.pojo.Indent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

@Component
public class MyTask {
    @Autowired
    private ApartmentMapper apartmentMapper;
    @Autowired
    private IndentMapper indentMapper;

    @Scheduled(cron = "0 0 4 * * ?")
    public void run() {
        List<Integer> ids=indentMapper.getDq(LocalDateTime.now());
        List<Integer> idAs=indentMapper.getDqA(LocalDateTime.now());
        if(ids.isEmpty()==false){
            indentMapper.setDq(ids);
        }
        if(idAs.isEmpty()==false){
            apartmentMapper.setCu(idAs);
        }
    }
}
